<?php
	
	session_start();
	require("connect.php");
	$link = connect_APO();	
	
	require("check.php");
	is_logged_in();
	is_admin();
	
	require("header+logoutB.php");
	headerL();
	
	require("randomString.php");
	
	echo "<html>
<body class='main'>

<FONT class='mainFont'>
  <CENTER>
    <!--<p><img src = 'images/apopic.jpg'></p>-->
    <br>
	<br>
	  <div class='headerTable'>
	  <b class='b1f'></b><b class='b2f'></b><b class='b3f'></b><b class='b4f'></b>
	  <div class='contentf'>
		  <div class = 'headerText'>
				Add Users Confirmation:
		  </div>";
/*	
	require("class.phpmailer.php");
	require("class.smtp.php");
	$mail = new PHPMailer();
	$mail->IsSMTP();
	$mail->SMTPAuth=true;
	$mail->SMTPSecure = "ssl";
	$mail->Host="smtp.gmail.com";
	$mail->Port = 465;
	$mail->Username="trthekeebler@gmail.com";
	$mail->Password="kl35z7";
	$mail->From = "trthekeebler@gmail.com";
	$mail->FromName = "Midweek Coordinator";
	$mail->Subject= "APO Midweek Service Username and Password";
*/	
	$numberToAdd = $_GET['numNew'];
	for($i=0; $i<$numberToAdd; $i += 1){
		$id = $_POST['id'.$i];
		$fname = $_POST['fname'.$i];
		$lname = $_POST['lname'.$i];
		$phone = $_POST['phone'.$i];
		$status = $_POST['status'.$i];
		
		if(strcmp($id,"")==0){
			echo "<div>User $fname $lname with id $id is not valid. This user was not created.";
		} else {
			$pass = $id.'!!';
			$sql="INSERT INTO `users` (`ID`,`Fname`,`Lname`,`PhoneNumber`,
`TotCredit`,`ML`,`Pass`, `Pending`, `MC`, `Status`, `PendingLocation`) VALUES ('$id', '$fname', '$lname', '$phone',
'0','0',PASSWORD('$pass'),'0', '0', '$status', '')";
			$result=mysql_query($sql);
			echo "<div>User $fname $lname with id $id was created successfully. Their password is currently '$pass'";
/*			$mail->Body="Hi, you have been signed up. Your id is $id, your password is $pass. Please go change your password immediately.";
			$mail->AltBody="Hi, you have been signed up. Your id is $id, your password is $pass. Please go change your password immediately.";
			$mail->WordWrap=50;
			$mail->AddAddress("$id@virginia.edu", "$fname");
			$mail->AddReplyTo("trthekeebler@gmail.com", "TR");
			$mail->IsHTML(true);
			if(!$mail->Send()){
				echo "Mailer Error: ".$mail->ErrorInfo;
			} else {
				echo "Message has been sent";
			}*/
		}
	}
	
		echo "</div>
	  <b class='b4f'></b><b class='b3f'></b><b class='b2f'></b><b class='b1f'></b></div>
  </CENTER>
</FONT>
</body>
</html>";

	require("footer.php");
	footer();
mysql_close($link);
?>
